import http from "./http";

let api = {};

let fileAddr =  process.env.VUE_APP_fileAddr;
// 图片上传
api.uploadfile = async (params,config)=>{
    let res = await http.post("/api/web/file/upload",params,config);
    res.url = fileAddr + res.name;
    return Promise.resolve(res);
}

// base64 上传
api.uploadImgData = async (params,config)=>{
    let res = await http.post("/api/web/file/imgdata",params,config);
    res.url = fileAddr + res.name;
    return Promise.resolve(res);
}


// 获取根据id获取用户的信息
api.getUserById = (params)=>{
    return http.get("/api/web/user/info",params);
}

//注册
api.register = (params) => {
    return http.post("/api/web/user/register",params);
}

//登陆
api.login = (params) => {
    return http.post("/api/web/user/login",params);
}

//登出
api.logout = (params) => {
    return http.post("/api/web/loginout",params);
}

//保存表单
api.save = (params) => {
    return http.post("/api/app/form/save",params)
}

// 删除
api.delete = (params) => {
    return http.post("/api/app/form/remove",params)
}

// 获取表单列表
api.list  =  (params) => {
    return http.get("/api/app/form/list",params)
}

// 获取表单详情
api.info  =  (params) => {
    return http.get("/api/app/form/info",params)
}

//提交
api.submit  =  (params) => {
    return http.post("/api/web/form/submit",params)
}
//获取某一个表单的数据
api.listData  =  (params) => {
    return http.get("/api/app/form/listData",params)
}
//删除表单的某一条数据
api.removeData  =  (params) => {
    return http.post("/api/app/form/removeData",params)
}
export default api;
